<template>
  <div class="spell-group-com">
    <div v-show="showDelete" class="list-item-delete  ">
      <span class="pull_left">{{ item.text }}</span>
      <span class="pull_right" @click.stop="deleteCurItem(item, index)"
        >删除</span
      >
    </div>
    <!-- 样式1 -->
    <!-- 样式1 未添加商品时 -->
    <div class="head ">
      <div class="opacity"></div>
      <div
        ref="scrollDiv"
        class="scroll-div flexC scrollbarsNO"
        style=" overflow-x: scroll;"
      >
        <span
          v-for="(items, indexs) in item.dataArr"
          :key="indexs"
          :class="$store.state.limitIndex == indexs ? 'on' : ''"
          >{{ items.name }}</span
        >
      </div>
    </div>
    <div v-if="item.stylesType == 0">
      <div
        v-if="item.dataArr[$store.state.limitIndex].shopId.length > 0"
        class="style-one"
        style="height:auto;"
      >
        <div
          v-for="(items, indexs) in item.dataArr[$store.state.limitIndex]
            .shopId"
          :key="indexs"
          style="margin-bottom:10px;"
        >
          <div class="for-wapper flexSc">
            <div class="one-left">
              <img
                :src="
                  $store.state.qiniu +
                    items.src.split(',')[0] +
                    $store.state.imgRotate
                "
                alt=""
                width="100%"
                height="100%"
              />
            </div>
            <div class="two-right">
              <div class="ntitle two-title">{{ items.goods_name }}</div>
              <div class="two-mid-prise flexC">
                <span style="font-size: 20px;color: #FF3B30;margin-right:10px"
                  >¥ {{ items.join_low_price }}</span
                >
                <span>¥ {{ items.sku_low_price }}</span>
              </div>
              <div class="two-mid-foot flexSc">
                <span class="two-btn-left">限时秒杀</span>
                <div class="two-btn-right">去抢购</div>
              </div>
            </div>
          </div>
        </div>

        <div class="two-more flexC" style="justify-content: space-around">
          <div class="flexSc more-wapper">
            <span>查看更多</span>
            <div>
              <img
                width="100%"
                height="100%"
                style="display:block;margin:2px 4px;"
                src="http://oss.ztwlxx.cn/jsynewshop%E6%8B%BC%E5%9B%A2%E5%8F%B3.svg"
              />
            </div>
          </div>
        </div>
      </div>
      <div v-else class="style-one">
        <div class="for-wapper flexSc">
          <div class="one-left">
            <img :src="Images.defaultImg" alt="" width="100%" height="100%" />
          </div>
          <div class="two-right">
            <div class="ntitle two-title">名称</div>
            <div class="two-mid-prise flexC">
              <span style="font-size: 20px;color: #FF3B30;margin-right:10px"
                >￥348</span
              >
              <span>￥348</span>
            </div>
            <div class="two-mid-foot flexSc">
              <span class="two-btn-left">限时秒杀</span>
              <div class="two-btn-right">去抢购</div>
            </div>
          </div>
        </div>

        <div class="two-more flexC" style="justify-content: space-around">
          <div class="flexSc more-wapper">
            <span>查看更多</span>
            <div>
              <img
                width="100%"
                height="100%"
                style="display:block;margin:2px 4px;"
                src="http://oss.ztwlxx.cn/jsynewshop%E6%8B%BC%E5%9B%A2%E5%8F%B3.svg"
              />
            </div>
          </div>
        </div>
      </div>
    </div>
    <div v-if="item.stylesType == 1">
      <div
        v-if="item.dataArr[$store.state.limitIndex].shopId.length > 0"
        class="style-two"
      >
        <div class="for-wapper flexSc">
          <div
            v-for="(items, indexs) in item.dataArr[$store.state.limitIndex]
              .shopId"
            :key="indexs"
          >
            <div class="two-left">
              <img
                :src="
                  $store.state.qiniu +
                    items.src.split(',')[0] +
                    $store.state.imgRotate
                "
                alt=""
                width="100%"
                height="100%"
              />
            </div>
            <div>
              <span style="font-size: 20px;margin-top:10px"
                >¥ {{ items.join_low_price }}</span
              >
            </div>
            <div>
              <span style="font-size:12px;margin-top:10px"
                >¥ {{ items.sku_low_price }}</span
              >
            </div>
          </div>
        </div>
        <div class="two-more flexC" style="justify-content: space-around">
          <div class="flexSc more-wapper">
            <span>查看更多</span>
            <div>
              <img
                width="100%"
                height="100%"
                style="display:block;margin:2px 4px;"
                src="http://oss.ztwlxx.cn/jsynewshop%E6%8B%BC%E5%9B%A2%E5%8F%B3.svg"
              />
            </div>
          </div>
        </div>
      </div>
      <div v-else class="style-two">
        <div class="for-wapper flexSc">
          <div v-for="items in 3" :key="items">
            <div class="two-left">
              <img :src="Images.defaultImg" alt="" width="100%" height="100%" />
            </div>
            <div>
              <span style="font-size: 20px;margin-top:10px">¥ 348</span>
            </div>
            <div>
              <span style="font-size:12px;margin-top:10px">￥348</span>
            </div>
          </div>
        </div>

        <div class="two-more flexC" style="justify-content: space-around">
          <div class="flexSc more-wapper">
            <span>查看更多</span>
            <div>
              <img
                width="100%"
                height="100%"
                style="display:block;margin:2px 4px;"
                src="http://oss.ztwlxx.cn/jsynewshop%E6%8B%BC%E5%9B%A2%E5%8F%B3.svg"
              />
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { Images } from "../../data";
export default {
  props: {
    item: {
      type: Object,
      default: () => {}
    },
    index: {
      type: Number,
      default: -1
    },
    showDelete: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      Images
    };
  },
  watch: {
    "$store.state.limitIndex"(v) {
      if (v < 2) {
        this.$refs.scrollDiv.scrollLeft = 0;
      } else {
        this.$refs.scrollDiv.scrollLeft = this.$refs.scrollDiv.scrollWidth;
      }
    }
  },
  methods: {
    deleteCurItem(e, i) {
      this.$emit("deleteCurItem", e, i);
    }
  }
};
</script>

<style lang="css" scoped>
.spell-group-com {
  position: relative;
}
.head {
  width: 100%;
  height: 42px;
  border-bottom: 1px solid #eee;
  background-color: #fff;
  position: relative;
}

.opacity {
  width: 36px;
  height: 42px;
  position: absolute;
  background: linear-gradient(
    to right,
    rgba(255, 255, 255, 0),
    rgba(255, 255, 255, 1)
  );
  right: 0;
  top: 0;
  z-index: 99;
}

.scroll-div {
  width: 100%;
  height: 100%;
  white-space: nowrap;
}

.scroll-div span {
  height: 98%;
  line-height: 44px;
  font-size: 16px;
  color: #333;
  margin-right: 16px;
}

.scroll-div span:nth-child(1) {
  margin-left: 16px;
}

.scroll-div span:last-child {
  margin-right: 16px;
}

.on {
  border-bottom: 1px solid #333;
  font-weight: 1000;
}
.style-one {
  height: 170px;
}
.style-two {
  height: 256px;
}
.style-one,
.style-two {
  width: 100%;
  background-color: #fff;
  padding: 15px 12px;
}
.show-style-two {
  padding: 0;
}
.show-style-two:last-child {
  border: 1px solid #ebebeb;
}

.one-left {
  width: 100px;
  height: 100px;
  background-color: skyblue;
  border-radius: 4px;
}
.two-left {
  width: 148px;
  height: 148px;
  background-color: skyblue;
  border-radius: 4px;
  margin-right: 10px;
}

.one-mid {
  margin-left: 16px;
  width: 200px;
  height: 100%;
}

.ntitle {
  margin: 0;
  height: 40px;
  font-size: 16px;
  color: #101010;
  display: -webkit-box;
  word-break: break-all;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: 0rpx !important;
}

.flexSc {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flexC {
  display: flex;
  align-items: center;
}
.one-mid-title,
.two-title {
  height: 42px;
  font-size: 16px;
  color: #333;
}

.one-mid-prise,
.two-mid-prise {
  width: 100%;
  height: 28px;
  margin-top: 6px;
  font-size: 14px;
  color: #999;
}

.one-mid-foot,
.two-mid-foot {
  width: 100%;
  height: 28px;
  margin-top: -5px;
}

.one-btn-left,
.two-btn-left {
  padding: 2px 10px;
  background: linear-gradient(130deg, #f1e0c6 0%, #e1c693 100%);
  border-radius: 10px;
  font-size: 12px;
  color: #865d44;
}

.one-btn-right,
.two-btn-right {
  width: 70px;
  height: 28px;
  line-height: 28px;
  font-size: 14px;
  color: #fff;
  text-align: center;
  background: #ff4035;
  border-radius: 4px;
}

.one-right {
  width: 14px;
  height: 66px;
  margin-left: 12px;
  font-size: 12px;
  color: #999;
  text-align: center;
}

.line {
  width: 1px;
  height: 100%;
  background-color: #ebebeb;
}

.more {
  width: 12px;
  height: 100%;
}

.two-right {
  width: 236px;
  height: 100%;
}

.two-more {
  width: 100%;
  height: 46px;
  background-color: #fff;
  margin: 0 auto;
}

.more-wapper {
  width: 72px;
  height: 20px;
  font-size: 16px;
  color: #999;
  justify-content: space-around;
}

.more-wapper div {
  width: 8px;
  height: 14px;
}
</style>
